<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.13.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Vulkan Memory Allocator: Frequenty asked questions</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Vulkan Memory Allocator
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.13.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search',false);
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="index.html">Vulkan Memory Allocator</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div><div class="header">
  <div class="headertitle"><div class="title">Frequenty asked questions</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><b>What is VMA?</b></p>
<p>Vulkan(R) Memory Allocator (VMA) is a software library for developers who use the Vulkan graphics API in their code. It is written in C++.</p>
<p><b>What is the license of VMA?</b></p>
<p>VMA is licensed under MIT, which means it is open source and free software.</p>
<p><b>What is the purpose of VMA?</b></p>
<p>VMA helps with handling one aspect of Vulkan usage, which is device memory management - allocation of <code>VkDeviceMemory</code> objects, and creation of <code>VkBuffer</code> and <code>VkImage</code> objects.</p>
<p><b>Do I need to use VMA?</b></p>
<p>You don't need to, but it may be beneficial in many cases. Vulkan is a complex and low-level API, so libraries like this that abstract certain aspects of the API and bring them to a higher level are useful. When developing any non-trivial Vulkan application, you likely need to use a memory allocator. Using VMA can save time compared to implementing your own.</p>
<p><b>When should I not use VMA?</b></p>
<p>While VMA is useful for most applications that use the Vulkan API, there are cases when it may be a better choice not to use it. For example, if the application is very simple, e.g. serving as a sample or a learning exercise to help you understand or teach others the basics of Vulkan, and it creates only a small number of buffers and images, then including VMA may be an overkill. Developing your own memory allocator may also be a good learning exercise.</p>
<p><b>What are the benefits of using VMA?</b></p>
<ol type="1">
<li>VMA helps in choosing the optimal memory type for your resource (buffer or image). In Vulkan, we have a two-level hierarchy of memory heaps and types with different flags, and each device can expose a different set of those. Implementing logic that would select the best memory type on each platform is a non-trivial task. VMA does that, expecting only a high-level description of the intended usage of your resource. For more information, see <a class="el" href="choosing_memory_type.html">Choosing memory type</a>.</li>
<li>VMA allocates large blocks of <code>VkDeviceMemory</code> and sub-allocates parts of them for your resources. Allocating a new block of device memory may be a time-consuming operation. Some platforms also have a limit on the maximum number of those blocks (<code>VkPhysicalDeviceLimits::maxMemoryAllocationCount</code>) as low as 4096, so allocating a separate one for each resource is not an option. Sub-allocating parts of a memory block requires implementing an allocation algorithm, which is a non-trivial task. VMA does that, using an advanced and efficient algorithm that works well in various use cases.</li>
<li>VMA offers a simple API that allows creating buffers and textures within one function call. In Vulkan, the creation of a resource is a multi-step process. You need to create a <code>VkBuffer</code> or <code>VkImage</code>, ask it for memory requirements, allocate a <code>VkDeviceMemory</code> object, and finally bind the resource to the memory block. VMA does that automatically under a simple API within one function call: <a class="el" href="group__group__alloc.html#gac72ee55598617e8eecca384e746bab51" title="Creates a new VkBuffer, allocates and binds memory for it.">vmaCreateBuffer()</a>, <a class="el" href="group__group__alloc.html#ga02a94f25679275851a53e82eacbcfc73" title="Function similar to vmaCreateBuffer().">vmaCreateImage()</a>.</li>
</ol>
<p>The library is doing much more under the hood. For example, it respects limits like <code>bufferImageGranularity</code>, <code>nonCoherentAtomSize</code>, and <code>VkMemoryDedicatedRequirements</code> automatically, so you don't need to think about it.</p>
<p><b>Which version should I pick?</b></p>
<p>You can just pick <a href="https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator">the latest version from the "master" branch</a>. It is kept in a good shape most of the time, compiling and working correctly, with no compatibility-breaking changes and no unfinished code.</p>
<p>If you want an even more stable version, you can pick <a href="https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/releases">the latest official release</a>. Current code from the master branch is occasionally tagged as a release, with <a href="https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/blob/master/CHANGELOG.md">CHANGELOG</a> carefully curated to enumerate all important changes since the previous version.</p>
<p>The library uses <a href="https://semver.org/">Semantic Versioning</a>, which means versions that only differ in the patch number are forward and backward compatible (e.g., only fixing some bugs), while versions that differ in the minor number are backward compatible (e.g., only adding new functions to the API, but not removing or changing existing ones).</p>
<p><b>How to integrate it with my code?</b></p>
<p>VMA is an STB-style single-header C++ library.</p>
<p>You can pull the entire GitHub repository, e.g. using Git submodules. The repository contains ancillary files like the Cmake script, Doxygen config file, sample application, test suite, and others. You can compile it as a library and link with your project.</p>
<p>However, a simpler way is taking the single file "include/vk_mem_alloc.h" and including it in your project. This extensive file contains all you need: a copyright notice, declarations of the public library interface (API), its internal implementation, and even the documentation in form of Doxygen-style comments.</p>
<p>The "STB style" means not everything is implemented as inline functions in the header file. You need to extract the internal implementation using a special macro. This means that in every .cpp file where you need to use the library you should <code>#include "vk_mem_alloc.h"</code> to include its public interface, but additionally in exactly one .cpp file you should <code>#define VMA_IMPLEMENTATION</code> before this <code>#include</code> to enable its internal implementation. For more information, see <a class="el" href="quick_start.html#quick_start_project_setup">Project setup</a>.</p>
<p><b>Does the library work with C or C++?</b></p>
<p>The internal implementation of VMA is written in C++. It is distributed in the source format, so you need a compiler supporting at least C++14 to build it.</p>
<p>However, the public interface of the library is written in C - using only enums, structs, and global functions, in the same style as Vulkan, so you can use the library in the C code.</p>
<p><b>I am not a fan of modern C++. Can I still use it?</b></p>
<p>Very likely yes. We acknowledge that many C++ developers, especially in the games industry, do not appreciate all the latest features that the language has to offer.</p>
<ul>
<li>VMA doesn't throw or catch any C++ exceptions. It reports errors by returning a <code>VkResult</code> value instead, just like Vulkan. If you don't use exceptions in your project, your code is not exception-safe, or even if you disable exception handling in the compiler options, you can still use VMA.</li>
<li>VMA doesn't use C++ run-time type information like <code>typeid</code> or <code>dynamic_cast</code>, so if you disable RTTI in the compiler options, you can still use the library.</li>
<li>VMA uses only a limited subset of standard C and C++ library. It doesn't use STL containers like <code>std::vector</code>, <code>map</code>, or <code>string</code>, either in the public interface nor in the internal implementation. It implements its own containers instead.</li>
<li>If you don't use the default heap memory allocator through <code>malloc/free</code> or <code>new/delete</code> but implement your own allocator instead, you can pass it to VMA and the library will use your functions for every dynamic heap allocation made internally, as well as passing it further to Vulkan functions. For details, see <a class="el" href="configuration.html#custom_memory_allocator">Custom host memory allocator</a>.</li>
</ul>
<p><b>Is it available for other programming languages?</b></p>
<p>VMA is a C++ library with C interface in similar style as Vulkan. An object-oriented C++ wrapper or bindings to other programming languages are out of scope of this project, but they are welcome as external projects. Some of them are listed in <a href="https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator?tab=readme-ov-file#see-also">README.md, "See also" section</a>, including binding to C++, Python, Rust, and Haskell. Before using any of them, please check if they are still maintained and updated to use a recent version of VMA.</p>
<p><b>What platforms does it support?</b></p>
<p>VMA relies only on Vulkan and some parts of the standard C and C++ library, so it supports any platform where a C++ compiler and Vulkan are available. It is developed mostly on Microsoft(R) Windows(R), but it has been successfully used in Linux(R), MacOS, Android, and even FreeBSD and Raspberry Pi.</p>
<p><b>Does it only work on AMD GPUs?</b></p>
<p>No! While VMA is published by AMD, it works on any GPU that supports Vulkan, whether a discrete PC graphics card, a processor integrated graphics, or a mobile SoC. It doesn't give AMD GPUs any advantage over any other GPUs.</p>
<p><b>What Vulkan versions and extensions are supported?</b></p>
<p>VMA is updated to support the latest versions of Vulkan. It currently supports Vulkan up to 1.4. The library also supports older versions down to the first release of Vulkan 1.0. Defining a higher minimum version support would help simplify the code, but we acknowledge that developers on some platforms like Android still use older versions, so the support is provided for all of them.</p>
<p>Among many extensions available for Vulkan, only a few interact with memory management. VMA can automatically take advantage of them. Some of them are: VK_EXT_memory_budget, VK_EXT_memory_priority, VK_KHR_external_memory_win32, and VK_KHR_maintenance* extensions that are later promoted to the new versions of the core Vulkan API.</p>
<p>To use them, it is your responsibility to validate if they are available on the current system and if so, enable them while creating the Vulkan device object. You also need to pass appropriate <a class="el" href="group__group__init.html#ga4f87c9100d154a65a4ad495f7763cf7c" title="Flags for created VmaAllocator.">VmaAllocatorCreateFlagBits</a> to inform VMA that they are enabled. Then, the library will automatically take advantage of them. For more information and the full list of supported extensions, see <a class="el" href="quick_start.html#quick_start_initialization_enabling_extensions">Enabling extensions</a>.</p>
<p><b>Does it support other graphics APIs, like Microsoft DirectX(R) 12?</b></p>
<p>No, but we offer an equivalent library for DirectX 12: <a href="https://github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator">D3D12 Memory Allocator</a>. It uses the same core allocation algorithm. It also shares many features with VMA, like the support for custom pools and virtual allocator. However, it is not identical in terms of the features supported. Its API also looks different, because while the interface of VMA is similar in style to Vulkan, the interface of D3D12MA is similar to DirectX 12.</p>
<p><b>Is the library lightweight?</b></p>
<p>It depends on how you define it. VMA is implemented with high-performance and real-time applications like video games in mind. The CPU performance overhead of using this library is low. It uses a high-quality allocation algorithm called Two-Level Segregated Fit (TLSF), which in most cases can find a free place for a new allocation in few steps. The library also doesn't perform too many CPU heap allocations. In many cases, the allocation happens with 0 new CPU heap allocations performed by the library. Even the creation of a <a class="el" href="struct_vma_allocation.html" title="Represents single memory allocation.">VmaAllocation</a> object doesn't typically feature an CPU allocation, because these objects are returned out of a dedicated memory pool.</p>
<p>On the other hand, however, VMA needs some extra memory and extra time to maintain the metadata about the occupied and free regions of the memory blocks, and the algorithms and data structures used must be generic enough to work well in most cases. If you develop your program for a very resource-constrained platform, a custom allocator simpler than VMA may be a better choice.</p>
<p><b>Does it have a documentation?</b></p>
<p>Yes! VMA comes with full documentation of all elements of the API (functions, structures, enums), as well as many generic chapters that provide an introduction, describe core concepts of the library, good practices, etc. The entire documentation is written in form of code comments inside "vk_mem_alloc.h", in Doxygen format. You can access it in multiple ways:</p>
<ul>
<li>Browsable online: <a href="https://gpuopen-librariesandsdks.github.io/VulkanMemoryAllocator/html/">https://gpuopen-librariesandsdks.github.io/VulkanMemoryAllocator/html/</a></li>
<li>Local HTML pages available after you clone the repository and open file "docs/html/index.html".</li>
<li>You can rebuild the documentation in HTML or some other format from the source code using Doxygen. Configuration file "Doxyfile" is part of the repository.</li>
<li>Finally, you can just read the comments preceding declarations of any public functions of the library.</li>
</ul>
<p><b>Is it a mature project?</b></p>
<p>Yes! The library is in development since June 2017, has over 1000 commits, over 400 issue tickets and pull requests (most of them resolved), and over 70 contributors. It is distributed together with Vulkan SDK. It is used by many software projects, including some large and popular ones like Qt or Blender, as well as some AAA games. According to the <a href="https://www.lunarg.com/2024-ecosystem-survey-progress-report-released/">LunarG 2024 Ecosystem Survey</a>, it is used by over 50% of Vulkan developers.</p>
<p><b>How can I contribute to the project?</b></p>
<p>If you have an idea for improvement or a feature request, you can go to <a href="https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator">the library repository</a> and create an Issue ticket, describing your idea. You can also implement it yourself by forking the repository, making changes to the code, and creating a Pull request.</p>
<p>If you want to ask a question, you can also create a ticket the same way. Before doing this, please make sure you read the relevant part of the Vulkan specification and VMA documentation, where you may find the answers to your question.</p>
<p>If you want to report a suspected bug, you can also create a ticket the same way. Before doing this, please put some effort into the investigation of whether the bug is really in the library and not in your code or in the Vulkan implementation (the GPU driver) on your platform:</p>
<ul>
<li>Enable Vulkan validation layer and make sure it is free from any errors.</li>
<li>Make sure <code>VMA_ASSERT</code> is defined to an implementation that can report a failure and not ignore it.</li>
<li>Try making your allocation using pure Vulkan functions rather than VMA and see if the bug persists.</li>
</ul>
<p><b>I found some compilation warnings. How can we fix them?</b></p>
<p>Seeing compiler warnings may be annoying to some developers, but it is a design decision to not fix all of them. Due to the nature of the C++ language, certain preprocessor macros can make some variables unused, function parameters unreferenced, or conditional expressions constant in some configurations. The code of this library should not be bigger or more complicated just to silence these warnings. It is recommended to disable such warnings instead. For more information, see <a class="el" href="general_considerations.html#general_considerations_features_not_supported">Features not supported</a>.</p>
<p>However, if you observe a warning that is really dangerous, e.g., about an implicit conversion from a larger to a smaller integer type, please report it and it will be fixed ASAP. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.13.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
